/*封装与金额信息的有关的ajax查询，添加等*/
require.config({
    paths: {
        "common": "../common/common"
    }
});
define(['common'], function(common) {
    var baseUrl = common.defaultStr();
    var money_url = {
        'modifyMoney': baseUrl + '/mgr/je/add.do',
        'getMoney': baseUrl + '/mgr/je/get.do',
        'getJe': baseUrl + '/mgr/je/get.do'
    };
    /*获取金额上限*/
    function getMoeny(query) {
        return $.ajax({
            type: "POST",
            url: money_url.getJe,
            data: JSON.stringify(query),
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true,
        }).done(
            handleSessionTimeOut
        );
    }
    /*更改金额上限*/
    function setMoney(query) {
        return $.ajax({
            type: "POST",
            url: money_url.modifyMoney,
            data: JSON.stringify(query),
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true,
        }).done(
            handleSessionTimeOut
        );
    }

    function handleSessionTimeOut(data) {
        if (data && data.retcode === '202') {
            location.reload();
        }
    }
    return {
        getMoeny,
        setMoney
    }

})
